package net.easyjava.framework.third.aws.sqs;

import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.sqs.AmazonSQSClient;
import com.amazonaws.services.sqs.model.ListQueuesResult;

import java.util.List;

/**
 * Created by wxnacy on 16/11/25.
 */
public class AWSSQSUtils {
    private String accessKey;
    private String secretKey;
    private String queueName;
    private AWSCredentials credentials;
    private AmazonSQSClient sqsClient;

    public AWSSQSUtils(String accessKey, String secretKey) {
        System.out.println("AWSSQSUtils.AWSSQSUtils");
        this.accessKey = accessKey;
        this.secretKey = secretKey;
    }
    public void init(){
        System.out.println("AWSSQSUtils.init");

        credentials = new BasicAWSCredentials(accessKey,secretKey);
        sqsClient = new AmazonSQSClient(credentials);
    }

    public List<String> listQueues(){
        ListQueuesResult result = sqsClient.listQueues();
        System.out.println("result.getSdkResponseMetadata().getRequestId() = " + result.getSdkResponseMetadata().getRequestId());

        return result.getQueueUrls();
    }

    public void setQueueName(String queueName) {
        System.out.println("AWSSQSUtils.setQueueName");
        this.queueName = queueName;
    }
}
